using System;
using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;

namespace ZYFramework.ObjectPool
{
    /// <summary>
    /// 对象策略接口
    /// </summary>
    /// <typeparam name="T">对象类型</typeparam>
    public interface IObjectPolicy<T>
    {
        #region 创建销毁

        /// <summary>
        /// 同步创建对象
        /// </summary>
        /// <returns>创建的对象</returns>
        T Create_Sync();

        /// <summary>
        /// 异步创建对象
        /// </summary>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>创建的对象</returns>
        UniTask<T> Create_Async(CancellationToken cancellationToken = default);

        /// <summary>
        /// 同步激活对象
        /// </summary>
        /// <param name="obj">要激活的对象</param>
        void Activate_Sync(T obj);

        /// <summary>
        /// 异步激活对象
        /// </summary>
        /// <param name="obj">要激活的对象</param>
        /// <param name="cancellationToken">取消令牌</param>
        UniTask Activate_Async(T obj, CancellationToken cancellationToken = default);

        /// <summary>
        /// 同步销毁对象
        /// </summary>
        /// <param name="obj">要销毁的对象</param>
        void Destroy_Sync(T obj);

        /// <summary>
        /// 异步销毁对象
        /// </summary>
        /// <param name="obj">要销毁的对象</param>
        /// <param name="cancellationToken">取消令牌</param>
        UniTask Destroy_Async(T obj, CancellationToken cancellationToken = default);
        #endregion

        #region 回收

        /// <summary>
        /// 同步回收对象
        /// </summary>
        /// <param name="obj">要回收的对象</param>
        void Recycle_Sync(T obj);

        /// <summary>
        /// 异步回收对象
        /// </summary>
        /// <param name="obj">要回收的对象</param>
        /// <param name="cancellationToken">取消令牌</param>
        UniTask Recycle_Async(T obj, CancellationToken cancellationToken = default);

        #endregion
    }
}
